﻿using AdminSystem.Applications;
using AdminSystem.Domain.User;
using AdminSystem.Write.API.Command.FarmsCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace AdminSystem.Write.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class FarmsController : ControllerBase
    {
        public FarmsController(IMediator mediator)
        {
            Mediator = mediator;
        }

        public IMediator Mediator { get; }
        /// <summary>
        /// 中介者添加养殖场
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<object>> AddFarms(FarmsAddCommand command)
        {
            return await Mediator.Send(command);
        }
        /// <summary>
        /// 中介者查询养殖场
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpGet]
        public async Task<ApiResult<Farms>> FarmsQuery()
        {
            FarmsQueryCommand command = new FarmsQueryCommand();
            return await Mediator.Send(command);

        }
    }
}
